<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- /fasttmp/mkdist-qt-4.3.5-1211793125/qtopia-core-opensource-src-4.3.5/src/corelib/kernel/qcoreapplication.cpp -->
<head>
  <title>Qt 4.3: QCoreApplication Class Reference</title>
  <link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><a href="http://www.trolltech.com/products/qt"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></a></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="modules.html"><font color="#004faf">Modules</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
<td align="right" valign="top" width="230"><a href="http://www.trolltech.com"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></a></td></tr></table><h1 align="center">QCoreApplication Class Reference<br /><sup><sup>[<a href="qtcore.html">QtCore</a> module]</sup></sup></h1>
<p>The QCoreApplication class provides an event loop for console Qt applications. <a href="#details">More...</a></p>
<pre> #include &lt;QCoreApplication&gt;</pre><p>Inherits <a href="qobject.html">QObject</a>.</p>
<p>Inherited by <a href="qapplication.html">QApplication</a>.</p>
<ul>
<li><a href="qcoreapplication-members.html">List of all members, including inherited members</a></li>
<li><a href="qcoreapplication-qt3.html">Qt 3 support members</a></li>
</ul>
<a name="public-types"></a>
<h3>Public Types</h3>
<ul>
<li><div class="fn"/>enum <b><a href="qcoreapplication.html#Encoding-enum">Encoding</a></b> { CodecForTr, UnicodeUTF8, DefaultCodec }</li>
<li><div class="fn"/>typedef <b><a href="qcoreapplication.html#EventFilter-typedef">EventFilter</a></b></li>
</ul>
<a name="properties"></a>
<h3>Properties</h3>
<ul>
<li><div class="fn"/><b><a href="qcoreapplication.html#applicationName-prop">applicationName</a></b> : QString</li>
<li><div class="fn"/><b><a href="qcoreapplication.html#organizationDomain-prop">organizationDomain</a></b> : QString</li>
<li><div class="fn"/><b><a href="qcoreapplication.html#organizationName-prop">organizationName</a></b> : QString</li>
</ul>
<ul>
<li><div class="fn"/>1 property inherited from <a href="qobject.html#properties">QObject</a></li>
</ul>
<a name="public-functions"></a>
<h3>Public Functions</h3>
<ul>
<li><div class="fn"/><b><a href="qcoreapplication.html#QCoreApplication">QCoreApplication</a></b> ( int &amp; <i>argc</i>, char ** <i>argv</i> )</li>
<li><div class="fn"/><b><a href="qcoreapplication.html#dtor.QCoreApplication">~QCoreApplication</a></b> ()</li>
<li><div class="fn"/>bool <b><a href="qcoreapplication.html#filterEvent">filterEvent</a></b> ( void * <i>message</i>, long * <i>result</i> )</li>
<li><div class="fn"/>virtual bool <b><a href="qcoreapplication.html#notify">notify</a></b> ( QObject * <i>receiver</i>, QEvent * <i>event</i> )</li>
<li><div class="fn"/>EventFilter <b><a href="qcoreapplication.html#setEventFilter">setEventFilter</a></b> ( EventFilter <i>filter</i> )</li>
<li><div class="fn"/>virtual bool <b><a href="qcoreapplication.html#winEventFilter">winEventFilter</a></b> ( MSG * <i>msg</i>, long * <i>result</i> )</li>
</ul>
<ul>
<li><div class="fn"/>29 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
</ul>
<a name="public-slots"></a>
<h3>Public Slots</h3>
<ul>
<li><div class="fn"/>void <b><a href="qcoreapplication.html#quit">quit</a></b> ()</li>
</ul>
<ul>
<li><div class="fn"/>1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
</ul>
<a name="signals"></a>
<h3>Signals</h3>
<ul>
<li><div class="fn"/>void <b><a href="qcoreapplication.html#aboutToQuit">aboutToQuit</a></b> ()</li>
</ul>
<ul>
<li><div class="fn"/>1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
</ul>
<a name="static-public-members"></a>
<h3>Static Public Members</h3>
<ul>
<li><div class="fn"/>void <b><a href="qcoreapplication.html#addLibraryPath">addLibraryPath</a></b> ( const QString &amp; <i>path</i> )</li>
<li><div class="fn"/>QString <b><a href="qcoreapplication.html#applicationDirPath">applicationDirPath</a></b> ()</li>
<li><div class="fn"/>QString <b><a href="qcoreapplication.html#applicationFilePath">applicationFilePath</a></b> ()</li>
<li><div class="fn"/>QString <b><a href="qcoreapplication.html#applicationName-prop">applicationName</a></b> ()</li>
<li><div class="fn"/>QStringList <b><a href="qcoreapplication.html#arguments">arguments</a></b> ()</li>
<li><div class="fn"/>bool <b><a href="qcoreapplication.html#closingDown">closingDown</a></b> ()</li>
<li><div class="fn"/>int <b><a href="qcoreapplication.html#exec">exec</a></b> ()</li>
<li><div class="fn"/>void <b><a href="qcoreapplication.html#exit">exit</a></b> ( int <i>returnCode</i> = 0 )</li>
<li><div class="fn"/>void <b><a href="qcoreapplication.html#flush">flush</a></b> ()</li>
<li><div class="fn"/>bool <b><a href="qcoreapplication.html#hasPendingEvents">hasPendingEvents</a></b> ()</li>
<li><div class="fn"/>void <b><a href="qcoreapplication.html#installTranslator">installTranslator</a></b> ( QTranslator * <i>translationFile</i> )</li>
<li><div class="fn"/>QCoreApplication * <b><a href="qcoreapplication.html#instance">instance</a></b> ()</li>
<li><div class="fn"/>QStringList <b><a href="qcoreapplication.html#libraryPaths">libraryPaths</a></b> ()</li>
<li><div class="fn"/>QString <b><a href="qcoreapplication.html#organizationDomain-prop">organizationDomain</a></b> ()</li>
<li><div class="fn"/>QString <b><a href="qcoreapplication.html#organizationName-prop">organizationName</a></b> ()</li>
<li><div class="fn"/>void <b><a href="qcoreapplication.html#postEvent">postEvent</a></b> ( QObject * <i>receiver</i>, QEvent * <i>event</i> )</li>
<li><div class="fn"/>void <b><a href="qcoreapplication.html#postEvent-2">postEvent</a></b> ( QObject * <i>receiver</i>, QEvent * <i>event</i>, int <i>priority</i> )</li>
<li><div class="fn"/>void <b><a href="qcoreapplication.html#processEvents">processEvents</a></b> ( QEventLoop::ProcessEventsFlags <i>flags</i> = QEventLoop::AllEvents )</li>
<li><div class="fn"/>void <b><a href="qcoreapplication.html#processEvents-2">processEvents</a></b> ( QEventLoop::ProcessEventsFlags <i>flags</i>, int <i>maxtime</i> )</li>
<li><div class="fn"/>void <b><a href="qcoreapplication.html#removeLibraryPath">removeLibraryPath</a></b> ( const QString &amp; <i>path</i> )</li>
<li><div class="fn"/>void <b><a href="qcoreapplication.html#removePostedEvents">removePostedEvents</a></b> ( QObject * <i>receiver</i> )</li>
<li><div class="fn"/>void <b><a href="qcoreapplication.html#removePostedEvents-2">removePostedEvents</a></b> ( QObject * <i>receiver</i>, int <i>eventType</i> )</li>
<li><div class="fn"/>void <b><a href="qcoreapplication.html#removeTranslator">removeTranslator</a></b> ( QTranslator * <i>translationFile</i> )</li>
<li><div class="fn"/>bool <b><a href="qcoreapplication.html#sendEvent">sendEvent</a></b> ( QObject * <i>receiver</i>, QEvent * <i>event</i> )</li>
<li><div class="fn"/>void <b><a href="qcoreapplication.html#sendPostedEvents">sendPostedEvents</a></b> ( QObject * <i>receiver</i>, int <i>event_type</i> )</li>
<li><div class="fn"/>void <b><a href="qcoreapplication.html#sendPostedEvents-2">sendPostedEvents</a></b> ()</li>
<li><div class="fn"/>void <b><a href="qcoreapplication.html#applicationName-prop">setApplicationName</a></b> ( const QString &amp; <i>application</i> )</li>
<li><div class="fn"/>void <b><a href="qcoreapplication.html#setAttribute">setAttribute</a></b> ( Qt::ApplicationAttribute <i>attribute</i>, bool <i>on</i> = true )</li>
<li><div class="fn"/>void <b><a href="qcoreapplication.html#setLibraryPaths">setLibraryPaths</a></b> ( const QStringList &amp; <i>paths</i> )</li>
<li><div class="fn"/>void <b><a href="qcoreapplication.html#organizationDomain-prop">setOrganizationDomain</a></b> ( const QString &amp; <i>orgDomain</i> )</li>
<li><div class="fn"/>void <b><a href="qcoreapplication.html#organizationName-prop">setOrganizationName</a></b> ( const QString &amp; <i>orgName</i> )</li>
<li><div class="fn"/>bool <b><a href="qcoreapplication.html#startingUp">startingUp</a></b> ()</li>
<li><div class="fn"/>bool <b><a href="qcoreapplication.html#testAttribute">testAttribute</a></b> ( Qt::ApplicationAttribute <i>attribute</i> )</li>
<li><div class="fn"/>QString <b><a href="qcoreapplication.html#translate">translate</a></b> ( const char * <i>context</i>, const char * <i>sourceText</i>, const char * <i>comment</i>, Encoding <i>encoding</i>, int <i>n</i> )</li>
<li><div class="fn"/>QString <b><a href="qcoreapplication.html#translate-2">translate</a></b> ( const char * <i>context</i>, const char * <i>sourceText</i>, const char * <i>comment</i> = 0, Encoding <i>encoding</i> = CodecForTr )</li>
</ul>
<ul>
<li><div class="fn"/>5 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
</ul>
<a name="related-non-members"></a>
<h3>Related Non-Members</h3>
<ul>
<li><div class="fn"/>void <b><a href="qcoreapplication.html#qAddPostRoutine">qAddPostRoutine</a></b> ( QtCleanUpFunction <i>ptr</i> )</li>
</ul>
<a name="macros"></a>
<h3>Macros</h3>
<ul>
<li><div class="fn"/><b><a href="qcoreapplication.html#Q_DECLARE_TR_FUNCTIONS">Q_DECLARE_TR_FUNCTIONS</a></b> (  <i>context</i> )</li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li><div class="fn"/>7 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
</ul>
<a name="details"></a>
<hr />
<h2>Detailed Description</h2>
<p>The QCoreApplication class provides an event loop for console Qt applications.</p>
<p>This class is used by non-GUI applications to provide their event loop. For non-GUI application that uses Qt, there should be exactly one QCoreApplication object. For GUI applications, see <a href="qapplication.html">QApplication</a>.</p>
<p>QCoreApplication contains the main event loop, where all events from the operating system (e.g&#x2e;, timer and network events) and other sources are processed and dispatched. It also handles the application's initialization and finalization, as well as system-wide and application-wide settings.</p>
<p>The command line arguments which QCoreApplication's constructor should be called with are accessible using <a href="qcoreapplication.html#arguments">arguments</a>(). The event loop is started with a call to <a href="qcoreapplication.html#exec">exec</a>(). Long running operations can call <a href="qcoreapplication.html#processEvents">processEvents</a>() to keep the application responsive.</p>
<p>Some Qt classes, such as <a href="qstring.html">QString</a>, can be used without a QCoreApplication object. However, in general, we recommend that you create a QCoreApplication or a <a href="qapplication.html">QApplication</a> object in your <tt>main()</tt> function as early as possible. The application will enter the event loop when <a href="qcoreapplication.html#exec">exec</a>() is called. <a href="qcoreapplication.html#exit">exit</a>() will not return until the event loop exits, e.g&#x2e;, when <a href="qcoreapplication.html#quit">quit</a>() is called.</p>
<p>An application has an <a href="qcoreapplication.html#applicationDirPath">applicationDirPath</a>() and an <a href="qcoreapplication.html#applicationFilePath">applicationFilePath</a>(). Translation files can be added or removed using <a href="qcoreapplication.html#installTranslator">installTranslator</a>() and <a href="qcoreapplication.html#removeTranslator">removeTranslator</a>(). Application strings can be translated using <a href="qcoreapplication.html#translate">translate</a>(). The <a href="qobject.html#tr">QObject::tr</a>() and <a href="qobject.html#trUtf8">QObject::trUtf8</a>() functions are implemented in terms of <a href="qcoreapplication.html#translate">translate</a>().</p>
<p>The class provides a <a href="qcoreapplication.html#quit">quit</a>() slot and an <a href="qcoreapplication.html#aboutToQuit">aboutToQuit</a>() signal.</p>
<p>Several static convenience functions are also provided. The QCoreApplication object is available from <a href="qcoreapplication.html#instance">instance</a>(). Events can be sent or posted using <a href="qcoreapplication.html#sendEvent">sendEvent</a>(), <a href="qcoreapplication.html#postEvent">postEvent</a>(), and <a href="qcoreapplication.html#sendPostedEvents">sendPostedEvents</a>(). Pending events can be removed with <a href="qcoreapplication.html#removePostedEvents">removePostedEvents</a>() or flushed with <a href="qcoreapplication.html#flush">flush</a>(). Library paths (see <a href="qlibrary.html">QLibrary</a>) can be retrieved with <a href="qcoreapplication.html#libraryPaths">libraryPaths</a>() and manipulated by <a href="qcoreapplication.html#setLibraryPaths">setLibraryPaths</a>(), <a href="qcoreapplication.html#addLibraryPath">addLibraryPath</a>(), and <a href="qcoreapplication.html#removeLibraryPath">removeLibraryPath</a>().</p>
<p>See also <a href="qapplication.html">QApplication</a>, <a href="qabstracteventdispatcher.html">QAbstractEventDispatcher</a>, <a href="qeventloop.html">QEventLoop</a>, <a href="threads-semaphores.html">Semaphores Example</a>, and <a href="threads-waitconditions.html">Wait Conditions Example</a>.</p>
<hr />
<h2>Member Type Documentation</h2>
<h3 class="fn"><a name="Encoding-enum"></a>enum QCoreApplication::Encoding</h3>
<p>This enum type defines the 8-bit encoding of character string arguments to <a href="qcoreapplication.html#translate">translate</a>():</p>
<p><table border="1" cellpadding="2" cellspacing="1" width="100%">
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
<tr><td valign="top"><tt>QCoreApplication::CodecForTr</tt></td><td align="center" valign="top"><tt>0</tt></td><td valign="top">The encoding specified by <a href="qtextcodec.html#codecForTr">QTextCodec::codecForTr</a>() (Latin-1 if none has been set).</td></tr>
<tr><td valign="top"><tt>QCoreApplication::UnicodeUTF8</tt></td><td align="center" valign="top"><tt>1</tt></td><td valign="top">UTF-8.</td></tr>
<tr><td valign="top"><tt>QCoreApplication::DefaultCodec</tt></td><td align="center" valign="top"><tt>CodecForTr</tt></td><td valign="top">(Obsolete) Use CodecForTr instead.</td></tr>
</table></p>
<p>See also <a href="qobject.html#tr">QObject::tr</a>(), <a href="qobject.html#trUtf8">QObject::trUtf8</a>(), and <a href="qstring.html#fromUtf8">QString::fromUtf8</a>().</p>
<h3 class="fn"><a name="EventFilter-typedef"></a>typedef QCoreApplication::EventFilter</h3>
<p>A function with the following signature that can be used as an event filter:</p>
<pre> bool myEventFilter(void *message, long *result);</pre>
<p>See also <a href="qcoreapplication.html#setEventFilter">setEventFilter</a>().</p>
<hr />
<h2>Property Documentation</h2>
<h3 class="fn"><a name="applicationName-prop"></a>applicationName : <a href="qstring.html">QString</a></h3>
<p>This property holds the name of this application.</p>
<p>The value is used by the <a href="qsettings.html">QSettings</a> class when it is constructed using the empty constructor. This saves having to repeat this information each time a <a href="qsettings.html">QSettings</a> object is created.</p>
<p>Access functions:</p>
<ul>
<li><div class="fn"/><b>QString applicationName ()</b></li>
<li><div class="fn"/><b>void setApplicationName ( const QString &amp; <i>application</i> )</b></li>
</ul>
<p>See also <a href="qcoreapplication.html#organizationName-prop">organizationName</a> and <a href="qcoreapplication.html#organizationDomain-prop">organizationDomain</a>.</p>
<h3 class="fn"><a name="organizationDomain-prop"></a>organizationDomain : <a href="qstring.html">QString</a></h3>
<p>This property holds the Internet domain of the organization that wrote this application.</p>
<p>The value is used by the <a href="qsettings.html">QSettings</a> class when it is constructed using the empty constructor. This saves having to repeat this information each time a <a href="qsettings.html">QSettings</a> object is created.</p>
<p>On Mac, <a href="qsettings.html">QSettings</a> uses organizationDomain() as the organization if it's not an empty string; otherwise it uses <a href="qcoreapplication.html#organizationName-prop">organizationName</a>(). On all other platforms, <a href="qsettings.html">QSettings</a> uses <a href="qcoreapplication.html#organizationName-prop">organizationName</a>() as the organization.</p>
<p>Access functions:</p>
<ul>
<li><div class="fn"/><b>QString organizationDomain ()</b></li>
<li><div class="fn"/><b>void setOrganizationDomain ( const QString &amp; <i>orgDomain</i> )</b></li>
</ul>
<p>See also <a href="qcoreapplication.html#organizationName-prop">organizationName</a> and <a href="qcoreapplication.html#applicationName-prop">applicationName</a>.</p>
<h3 class="fn"><a name="organizationName-prop"></a>organizationName : <a href="qstring.html">QString</a></h3>
<p>This property holds the name of the organization that wrote this application.</p>
<p>The value is used by the <a href="qsettings.html">QSettings</a> class when it is constructed using the empty constructor. This saves having to repeat this information each time a <a href="qsettings.html">QSettings</a> object is created.</p>
<p>On Mac, <a href="qsettings.html">QSettings</a> uses <a href="qcoreapplication.html#organizationDomain-prop">organizationDomain</a>() as the organization if it's not an empty string; otherwise it uses organizationName(). On all other platforms, <a href="qsettings.html">QSettings</a> uses organizationName() as the organization.</p>
<p>Access functions:</p>
<ul>
<li><div class="fn"/><b>QString organizationName ()</b></li>
<li><div class="fn"/><b>void setOrganizationName ( const QString &amp; <i>orgName</i> )</b></li>
</ul>
<p>See also <a href="qcoreapplication.html#organizationDomain-prop">organizationDomain</a> and <a href="qcoreapplication.html#applicationName-prop">applicationName</a>.</p>
<hr />
<h2>Member Function Documentation</h2>
<h3 class="fn"><a name="QCoreApplication"></a>QCoreApplication::QCoreApplication ( int &amp; <i>argc</i>, char ** <i>argv</i> )</h3>
<p>Constructs a Qt kernel application. Kernel applications are applications without a graphical user interface. These type of applications are used at the console or as server processes.</p>
<p>The <i>argc</i> and <i>argv</i> arguments are processed by the application, and made available in a more convenient form by the <a href="qcoreapplication.html#arguments">arguments</a>() function.</p>
<p><b>Warning:</b> The data pointed to by <i>argc</i> and <i>argv</i> must stay valid for the entire lifetime of the <a href="qcoreapplication.html">QCoreApplication</a> object.</p>
<h3 class="fn"><a name="dtor.QCoreApplication"></a>QCoreApplication::~QCoreApplication ()</h3>
<p>Destroys the <a href="qcoreapplication.html">QCoreApplication</a> object.</p>
<h3 class="fn"><a name="aboutToQuit"></a>void QCoreApplication::aboutToQuit ()&nbsp;&nbsp;<tt> [signal]</tt></h3>
<p>This signal is emitted when the application is about to quit the main event loop, e.g&#x2e; when the event loop level drops to zero. This may happen either after a call to <a href="qcoreapplication.html#quit">quit</a>() from inside the application or when the users shuts down the entire desktop session.</p>
<p>The signal is particularly useful if your application has to do some last-second cleanup. Note that no user interaction is possible in this state.</p>
<p>See also <a href="qcoreapplication.html#quit">quit</a>().</p>
<h3 class="fn"><a name="addLibraryPath"></a>void QCoreApplication::addLibraryPath ( const <a href="qstring.html">QString</a> &amp; <i>path</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Appends <i>path</i> to the end of the library path list. If <i>path</i> is empty or already in the path list, the path list is not changed.</p>
<p>The default path list consists of a single entry, the installation directory for plugins. The default installation directory for plugins is <tt>INSTALL/plugins</tt>, where <tt>INSTALL</tt> is the directory where Qt was installed.</p>
<p>See also <a href="qcoreapplication.html#removeLibraryPath">removeLibraryPath</a>(), <a href="qcoreapplication.html#libraryPaths">libraryPaths</a>(), and <a href="qcoreapplication.html#setLibraryPaths">setLibraryPaths</a>().</p>
<h3 class="fn"><a name="applicationDirPath"></a><a href="qstring.html">QString</a> QCoreApplication::applicationDirPath ()&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Returns the directory that contains the application executable.</p>
<p>For example, if you have installed Qt in the <tt>C:\Trolltech\Qt</tt> directory, and you run the <tt>regexp</tt> example, this function will return &quot;C:/Trolltech/Qt/examples/tools/regexp&quot;.</p>
<p>On Mac OS X this will point to the directory actually containing the executable, which may be inside of an application bundle (if the application is bundled).</p>
<p><b>Warning:</b> On Unix, this function assumes that argv[0] contains the file name of the executable (which it normally does). It also assumes that the current directory hasn't been changed by the application.</p>
<p>See also <a href="qcoreapplication.html#applicationFilePath">applicationFilePath</a>().</p>
<h3 class="fn"><a name="applicationFilePath"></a><a href="qstring.html">QString</a> QCoreApplication::applicationFilePath ()&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Returns the file path of the application executable.</p>
<p>For example, if you have installed Qt in the <tt>/usr/local/qt</tt> directory, and you run the <tt>regexp</tt> example, this function will return &quot;/usr/local/qt/examples/tools/regexp/regexp&quot;.</p>
<p><b>Warning:</b> On Unix, this function assumes that argv[0] contains the file name of the executable (which it normally does). It also assumes that the current directory hasn't been changed by the application.</p>
<p>See also <a href="qcoreapplication.html#applicationDirPath">applicationDirPath</a>().</p>
<h3 class="fn"><a name="arguments"></a><a href="qstringlist.html">QStringList</a> QCoreApplication::arguments ()&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Returns the list of command-line arguments.</p>
<p>arguments().at(0) is the program name, arguments().at(1) is the first argument, and arguments().last() is the last argument.</p>
<p>Calling this function is slow - you should store the result in a variable when parsing the command line.</p>
<p><b>Warning:</b> On Unix, this list is built from the argc and argv parameters passed to the constructor in the main() function. The string-data in argv is interpreted using <a href="qstring.html#fromLocal8Bit">QString::fromLocal8Bit</a>(); hence it is not possible to pass i.e&#x2e; Japanese command line arguments on a system that runs in a latin1 locale. Most modern Unix systems do not have this limitation, as they are Unicode based.</p>
<p>On NT-based Windows, this limitation does not apply either.</p>
<p>This function was introduced in Qt 4.1.</p>
<h3 class="fn"><a name="closingDown"></a>bool QCoreApplication::closingDown ()&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Returns true if the application objects are being destroyed; otherwise returns false.</p>
<p>See also <a href="qcoreapplication.html#startingUp">startingUp</a>().</p>
<h3 class="fn"><a name="exec"></a>int QCoreApplication::exec ()&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Enters the main event loop and waits until <a href="qcoreapplication.html#exit">exit</a>() is called. Returns the value that was set to <a href="qcoreapplication.html#exit">exit</a>() (which is 0 if <a href="qcoreapplication.html#exit">exit</a>() is called via <a href="qcoreapplication.html#quit">quit</a>()).</p>
<p>It is necessary to call this function to start event handling. The main event loop receives events from the window system and dispatches these to the application widgets.</p>
<p>To make your application perform idle processing (i.e&#x2e; executing a special function whenever there are no pending events), use a <a href="qtimer.html">QTimer</a> with 0 timeout. More advanced idle processing schemes can be achieved using <a href="qcoreapplication.html#processEvents">processEvents</a>().</p>
<p>See also <a href="qcoreapplication.html#quit">quit</a>(), <a href="qcoreapplication.html#exit">exit</a>(), <a href="qcoreapplication.html#processEvents">processEvents</a>(), and <a href="qapplication.html#exec">QApplication::exec</a>().</p>
<h3 class="fn"><a name="exit"></a>void QCoreApplication::exit ( int <i>returnCode</i> = 0 )&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Tells the application to exit with a return code.</p>
<p>After this function has been called, the application leaves the main event loop and returns from the call to <a href="qcoreapplication.html#exec">exec</a>(). The <a href="qcoreapplication.html#exec">exec</a>() function returns <i>returnCode</i>. If the event loop is not running, this function does nothing.</p>
<p>By convention, a <i>returnCode</i> of 0 means success, and any non-zero value indicates an error.</p>
<p>Note that unlike the C library function of the same name, this function <i>does</i> return to the caller -- it is event processing that stops.</p>
<p>See also <a href="qcoreapplication.html#quit">quit</a>() and <a href="qcoreapplication.html#exec">exec</a>().</p>
<h3 class="fn"><a name="filterEvent"></a>bool QCoreApplication::filterEvent ( void * <i>message</i>, long * <i>result</i> )</h3>
<p>Sends <i>message</i> through the event filter that was set by <a href="qcoreapplication.html#setEventFilter">setEventFilter</a>(). If no event filter has been set, this function returns false; otherwise, this function returns the result of the event filter function in the <i>result</i> parameter.</p>
<p>See also <a href="qcoreapplication.html#setEventFilter">setEventFilter</a>().</p>
<h3 class="fn"><a name="flush"></a>void QCoreApplication::flush ()&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Flushes the platform specific event queues.</p>
<p>If you are doing graphical changes inside a loop that does not return to the event loop on asynchronous window systems like X11 or double buffered window systems like Mac OS X, and you want to visualize these changes immediately (e.g&#x2e; Splash Screens), call this function.</p>
<p>See also <a href="qcoreapplication.html#sendPostedEvents">sendPostedEvents</a>().</p>
<h3 class="fn"><a name="hasPendingEvents"></a>bool QCoreApplication::hasPendingEvents ()&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>This function returns true if there are pending events; otherwise returns false. Pending events can be either from the window system or posted events using <a href="qcoreapplication.html#postEvent">postEvent</a>().</p>
<p>See also <a href="qabstracteventdispatcher.html#hasPendingEvents">QAbstractEventDispatcher::hasPendingEvents</a>().</p>
<h3 class="fn"><a name="installTranslator"></a>void QCoreApplication::installTranslator ( <a href="qtranslator.html">QTranslator</a> * <i>translationFile</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Adds the translation file <i>translationFile</i> to the list of translation files to be used for translations.</p>
<p>Multiple translation files can be installed. Translations are searched for in the last installed translation file on, back to the first installed translation file. The search stops as soon as a matching translation is found.</p>
<p>See also <a href="qcoreapplication.html#removeTranslator">removeTranslator</a>(), <a href="qcoreapplication.html#translate">translate</a>(), and <a href="qtranslator.html#load">QTranslator::load</a>().</p>
<h3 class="fn"><a name="instance"></a>QCoreApplication * QCoreApplication::instance ()&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Returns a pointer to the application's <a href="qcoreapplication.html">QCoreApplication</a> (or <a href="qapplication.html">QApplication</a>) instance.</p>
<h3 class="fn"><a name="libraryPaths"></a><a href="qstringlist.html">QStringList</a> QCoreApplication::libraryPaths ()&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Returns a list of paths that the application will search when dynamically loading libraries.</p>
<p>Qt provides default library paths, but they can also be set using a <a href="qt-conf.html">qt.conf</a> file. Paths specified in this file will override default values.</p>
<p>This list will include the installation directory for plugins if it exists (the default installation directory for plugins is <tt>INSTALL/plugins</tt>, where <tt>INSTALL</tt> is the directory where Qt was installed). The directory of the application executable (NOT the working directory) is always added, as well as the colon separated entries of the QT_PLUGIN_PATH environment variable.</p>
<p>If you want to iterate over the list, you can use the <a href="containers.html#foreach">foreach</a> pseudo-keyword:</p>
<pre> foreach (QString path, app.libraryPaths())
     do_something(path);</pre>
<p>See also <a href="qcoreapplication.html#setLibraryPaths">setLibraryPaths</a>(), <a href="qcoreapplication.html#addLibraryPath">addLibraryPath</a>(), <a href="qcoreapplication.html#removeLibraryPath">removeLibraryPath</a>(), <a href="qlibrary.html">QLibrary</a>, and <a href="plugins-howto.html">How to Create Qt Plugins</a>.</p>
<h3 class="fn"><a name="notify"></a>bool QCoreApplication::notify ( <a href="qobject.html">QObject</a> * <i>receiver</i>, <a href="qevent.html">QEvent</a> * <i>event</i> )&nbsp;&nbsp;<tt> [virtual]</tt></h3>
<p>Sends <i>event</i> to <i>receiver</i>: <i>receiver</i>-&gt;event(<i>event</i>). Returns the value that is returned from the receiver's event handler.</p>
<p>For certain types of events (e.g&#x2e; mouse and key events), the event will be propagated to the receiver's parent and so on up to the top-level object if the receiver is not interested in the event (i.e&#x2e;, it returns false).</p>
<p>There are five different ways that events can be processed; reimplementing this virtual function is just one of them. All five approaches are listed below:</p>
<ol type="1">
<li>Reimplementing paintEvent(), mousePressEvent() and so on. This is the commonest, easiest and least powerful way.</li>
<li>Reimplementing this function. This is very powerful, providing complete control; but only one subclass can be active at a time.</li>
<li>Installing an event filter on <a href="qcoreapplication.html#instance">QCoreApplication::instance</a>(). Such an event filter is able to process all events for all widgets, so it's just as powerful as reimplementing notify(); furthermore, it's possible to have more than one application-global event filter. Global event filters even see mouse events for <a href="qwidget.html#enabled-prop">disabled widgets</a>.</li>
<li>Reimplementing <a href="qobject.html#event">QObject::event</a>() (as <a href="qwidget.html">QWidget</a> does). If you do this you get Tab key presses, and you get to see the events before any widget-specific event filters.</li>
<li>Installing an event filter on the object. Such an event filter gets all the events except Tab and Shift-Tab key presses.</li>
</ol>
<p>See also <a href="qobject.html#event">QObject::event</a>() and <a href="qobject.html#installEventFilter">installEventFilter</a>().</p>
<h3 class="fn"><a name="postEvent"></a>void QCoreApplication::postEvent ( <a href="qobject.html">QObject</a> * <i>receiver</i>, <a href="qevent.html">QEvent</a> * <i>event</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Adds the event <i>event</i>, with the object <i>receiver</i> as the receiver of the event, to an event queue and returns immediately.</p>
<p>The event must be allocated on the heap since the post event queue will take ownership of the event and delete it once it has been posted. It is <i>not safe</i> to modify or delete the event after it has been posted.</p>
<p>When control returns to the main event loop, all events that are stored in the queue will be sent using the <a href="qcoreapplication.html#notify">notify</a>() function.</p>
<p>Events are processed in the order posted. For more control over the processing order, use the postEvent() overload below, which takes a priority argument. This function posts all event with a <a href="qt.html#EventPriority-enum">Qt::NormalEventPriority</a>.</p>
<p><b>Note:</b> This function is <a href="threads.html#thread-safe">thread-safe</a>.</p>
<p>See also <a href="qcoreapplication.html#sendEvent">sendEvent</a>(), <a href="qcoreapplication.html#notify">notify</a>(), and <a href="qcoreapplication.html#sendPostedEvents">sendPostedEvents</a>().</p>
<h3 class="fn"><a name="postEvent-2"></a>void QCoreApplication::postEvent ( <a href="qobject.html">QObject</a> * <i>receiver</i>, <a href="qevent.html">QEvent</a> * <i>event</i>, int <i>priority</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>Adds the event <i>event</i>, with the object <i>receiver</i> as the receiver of the event, to an event queue and returns immediately.</p>
<p>The event must be allocated on the heap since the post event queue will take ownership of the event and delete it once it has been posted. It is <i>not safe</i> to modify or delete the event after it has been posted.</p>
<p>When control returns to the main event loop, all events that are stored in the queue will be sent using the <a href="qcoreapplication.html#notify">notify</a>() function.</p>
<p>Events are sorted in descending <i>priority</i> order, i.e&#x2e; events with a high <i>priority</i> are queued before events with a lower <i>priority</i>. The <i>priority</i> can be any integer value, i.e&#x2e; between INT_MAX and INT_MIN, inclusive; see <a href="qt.html#EventPriority-enum">Qt::EventPriority</a> for more details. Events with equal <i>priority</i> will be processed in the order posted.</p>
<p><b>Note:</b> This function is <a href="threads.html#thread-safe">thread-safe</a>.</p>
<p>This function was introduced in Qt 4.3.</p>
<p>See also <a href="qcoreapplication.html#sendEvent">sendEvent</a>(), <a href="qcoreapplication.html#notify">notify</a>(), <a href="qcoreapplication.html#sendPostedEvents">sendPostedEvents</a>(), and <a href="qt.html#EventPriority-enum">Qt::EventPriority</a>.</p>
<h3 class="fn"><a name="processEvents"></a>void QCoreApplication::processEvents ( <a href="qeventloop.html#ProcessEventsFlag-enum">QEventLoop::ProcessEventsFlags</a> <i>flags</i> = QEventLoop::AllEvents )&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Processes all pending events for the calling thread according to the specified <i>flags</i> until there are no more events to process.</p>
<p>You can call this function occasionally when your program is busy performing a long operation (e.g&#x2e; copying a file).</p>
<p>In event you are running a local loop which calls this function continuously, without an event loop, the <a href="qevent.html#Type-enum">DeferredDelete</a> events will not be processed. This can affect the behaviour of widgets, e.g&#x2e; <a href="qtooltip.html">QToolTip</a>, that rely on <a href="qevent.html#Type-enum">DeferredDelete</a> events to function properly. An alternative would be to call <a href="qcoreapplication.html#sendPostedEvents">sendPostedEvents()</a> from within that local loop.</p>
<p>Calling this function processes events only for the calling thread.</p>
<p><b>Note:</b> This function is <a href="threads.html#thread-safe">thread-safe</a>.</p>
<p>See also <a href="qcoreapplication.html#exec">exec</a>(), <a href="qtimer.html">QTimer</a>, <a href="qeventloop.html#processEvents">QEventLoop::processEvents</a>(), <a href="qcoreapplication.html#flush">flush</a>(), and <a href="qcoreapplication.html#sendPostedEvents">sendPostedEvents</a>().</p>
<h3 class="fn"><a name="processEvents-2"></a>void QCoreApplication::processEvents ( <a href="qeventloop.html#ProcessEventsFlag-enum">QEventLoop::ProcessEventsFlags</a> <i>flags</i>, int <i>maxtime</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>Processes pending events for the calling thread for <i>maxtime</i> milliseconds or until there are no more events to process, whichever is shorter.</p>
<p>You can call this function occasionally when you program is busy doing a long operation (e.g&#x2e; copying a file).</p>
<p>Calling this function processes events only for the calling thread.</p>
<p><b>Note:</b> This function is <a href="threads.html#thread-safe">thread-safe</a>.</p>
<p>See also <a href="qcoreapplication.html#exec">exec</a>(), <a href="qtimer.html">QTimer</a>, and <a href="qeventloop.html#processEvents">QEventLoop::processEvents</a>().</p>
<h3 class="fn"><a name="quit"></a>void QCoreApplication::quit ()&nbsp;&nbsp;<tt> [static slot]</tt></h3>
<p>Tells the application to exit with return code 0 (success). Equivalent to calling QCoreApplication::exit(0).</p>
<p>It's common to connect the <a href="qapplication.html#lastWindowClosed">QApplication::lastWindowClosed</a>() signal to quit(), and you also often connect e.g&#x2e; <a href="qabstractbutton.html#clicked">QAbstractButton::clicked</a>() or signals in <a href="qaction.html">QAction</a>, <a href="qmenu.html">QMenu</a>, or <a href="qmenubar.html">QMenuBar</a> to it.</p>
<p>Example:</p>
<pre> QPushButton *quitButton = new QPushButton(&quot;Quit&quot;);
 connect(quitButton, SIGNAL(clicked()), &amp;app, SLOT(quit()));</pre>
<p>See also <a href="qcoreapplication.html#exit">exit</a>(), <a href="qcoreapplication.html#aboutToQuit">aboutToQuit</a>(), and <a href="qapplication.html#lastWindowClosed">QApplication::lastWindowClosed</a>().</p>
<h3 class="fn"><a name="removeLibraryPath"></a>void QCoreApplication::removeLibraryPath ( const <a href="qstring.html">QString</a> &amp; <i>path</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Removes <i>path</i> from the library path list. If <i>path</i> is empty or not in the path list, the list is not changed.</p>
<p>See also <a href="qcoreapplication.html#addLibraryPath">addLibraryPath</a>(), <a href="qcoreapplication.html#libraryPaths">libraryPaths</a>(), and <a href="qcoreapplication.html#setLibraryPaths">setLibraryPaths</a>().</p>
<h3 class="fn"><a name="removePostedEvents"></a>void QCoreApplication::removePostedEvents ( <a href="qobject.html">QObject</a> * <i>receiver</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Removes all events posted using <a href="qcoreapplication.html#postEvent">postEvent</a>() for <i>receiver</i>.</p>
<p>The events are <i>not</i> dispatched, instead they are removed from the queue. You should never need to call this function. If you do call it, be aware that killing events may cause <i>receiver</i> to break one or more invariants.</p>
<p><b>Note:</b> This function is <a href="threads.html#thread-safe">thread-safe</a>.</p>
<h3 class="fn"><a name="removePostedEvents-2"></a>void QCoreApplication::removePostedEvents ( <a href="qobject.html">QObject</a> * <i>receiver</i>, int <i>eventType</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>Removes all events of the given <i>eventType</i> that were posted using <a href="qcoreapplication.html#postEvent">postEvent</a>() for <i>receiver</i>.</p>
<p>The events are <i>not</i> dispatched, instead they are removed from the queue. You should never need to call this function. If you do call it, be aware that killing events may cause <i>receiver</i> to break one or more invariants.</p>
<p>If <i>receiver</i> is null, the events of <i>eventType</i> are removed for all objects. If <i>eventType</i> is 0, all the events are removed for <i>receiver</i>.</p>
<p><b>Note:</b> This function is <a href="threads.html#thread-safe">thread-safe</a>.</p>
<p>This function was introduced in Qt 4.3.</p>
<h3 class="fn"><a name="removeTranslator"></a>void QCoreApplication::removeTranslator ( <a href="qtranslator.html">QTranslator</a> * <i>translationFile</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Removes the translation file <i>translationFile</i> from the list of translation files used by this application. (It does not delete the translation file from the file system.)</p>
<p>See also <a href="qcoreapplication.html#installTranslator">installTranslator</a>(), <a href="qcoreapplication.html#translate">translate</a>(), and <a href="qobject.html#tr">QObject::tr</a>().</p>
<h3 class="fn"><a name="sendEvent"></a>bool QCoreApplication::sendEvent ( <a href="qobject.html">QObject</a> * <i>receiver</i>, <a href="qevent.html">QEvent</a> * <i>event</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Sends event <i>event</i> directly to receiver <i>receiver</i>, using the <a href="qcoreapplication.html#notify">notify</a>() function. Returns the value that was returned from the event handler.</p>
<p>The event is <i>not</i> deleted when the event has been sent. The normal approach is to create the event on the stack, for example:</p>
<pre> QMouseEvent event(QEvent::MouseButtonPress, pos, 0, 0, 0);
 QApplication::sendEvent(mainWindow, &amp;event);</pre>
<p>See also <a href="qcoreapplication.html#postEvent">postEvent</a>() and <a href="qcoreapplication.html#notify">notify</a>().</p>
<h3 class="fn"><a name="sendPostedEvents"></a>void QCoreApplication::sendPostedEvents ( <a href="qobject.html">QObject</a> * <i>receiver</i>, int <i>event_type</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Immediately dispatches all events which have been previously queued with <a href="qcoreapplication.html#postEvent">QCoreApplication::postEvent</a>() and which are for the object <i>receiver</i> and have the event type <i>event_type</i>.</p>
<p>Note that events from the window system are <i>not</i> dispatched by this function, but by <a href="qcoreapplication.html#processEvents">processEvents</a>().</p>
<p>If <i>receiver</i> is null, the events of <i>event_type</i> are sent for all objects. If <i>event_type</i> is 0, all the events are sent for <i>receiver</i>.</p>
<p>See also <a href="qcoreapplication.html#flush">flush</a>() and <a href="qcoreapplication.html#postEvent">postEvent</a>().</p>
<h3 class="fn"><a name="sendPostedEvents-2"></a>void QCoreApplication::sendPostedEvents ()&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>Dispatches all posted events, i.e&#x2e; empties the event queue.</p>
<h3 class="fn"><a name="setAttribute"></a>void QCoreApplication::setAttribute ( <a href="qt.html#ApplicationAttribute-enum">Qt::ApplicationAttribute</a> <i>attribute</i>, bool <i>on</i> = true )&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Sets the attribute <i>attribute</i> if <i>on</i> is true; otherwise clears the attribute.</p>
<p>One of the attributes that can be set with this method is <a href="qt.html#ApplicationAttribute-enum">Qt::AA_ImmediateWidgetCreation</a>. It tells Qt to create toplevel windows immediately. Normally, resources for widgets are allocated on demand to improve efficiency and minimize resource usage. Therefore, if it is important to minimize resource consumption, do not set this attribute.</p>
<p>See also <a href="qcoreapplication.html#testAttribute">testAttribute</a>().</p>
<h3 class="fn"><a name="setEventFilter"></a><a href="qcoreapplication.html#EventFilter-typedef">EventFilter</a> QCoreApplication::setEventFilter ( <a href="qcoreapplication.html#EventFilter-typedef">EventFilter</a> <i>filter</i> )</h3>
<p>Sets the event filter <i>filter</i>. Returns a pointer to the filter function previously defined.</p>
<p>The event filter is a function that is called for every message received in all threads. This does <i>not</i> include messages to objects that are not handled by Qt.</p>
<p>The function can return true to stop the event to be processed by Qt, or false to continue with the standard event processing.</p>
<p>Only one filter can be defined, but the filter can use the return value to call the previously set event filter. By default, no filter is set (i.e&#x2e;, the function returns 0).</p>
<p>See also <a href="qobject.html#installEventFilter">installEventFilter</a>().</p>
<h3 class="fn"><a name="setLibraryPaths"></a>void QCoreApplication::setLibraryPaths ( const <a href="qstringlist.html">QStringList</a> &amp; <i>paths</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Sets the list of directories to search when loading libraries to <i>paths</i>. All existing paths will be deleted and the path list will consist of the paths given in <i>paths</i>.</p>
<p>See also <a href="qcoreapplication.html#libraryPaths">libraryPaths</a>(), <a href="qcoreapplication.html#addLibraryPath">addLibraryPath</a>(), <a href="qcoreapplication.html#removeLibraryPath">removeLibraryPath</a>(), and <a href="qlibrary.html">QLibrary</a>.</p>
<h3 class="fn"><a name="startingUp"></a>bool QCoreApplication::startingUp ()&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Returns true if an application object has not been created yet; otherwise returns false.</p>
<p>See also <a href="qcoreapplication.html#closingDown">closingDown</a>().</p>
<h3 class="fn"><a name="testAttribute"></a>bool QCoreApplication::testAttribute ( <a href="qt.html#ApplicationAttribute-enum">Qt::ApplicationAttribute</a> <i>attribute</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Returns true if attribute <i>attribute</i> is set; otherwise returns false.</p>
<p>See also <a href="qcoreapplication.html#setAttribute">setAttribute</a>().</p>
<h3 class="fn"><a name="translate"></a><a href="qstring.html">QString</a> QCoreApplication::translate ( const char * <i>context</i>, const char * <i>sourceText</i>, const char * <i>comment</i>, <a href="qcoreapplication.html#Encoding-enum">Encoding</a> <i>encoding</i>, int <i>n</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Returns the translation text for <i>sourceText</i>, by querying the installed translation files. The translation files are searched from the most recently installed file back to the first installed file.</p>
<p><a href="qobject.html#tr">QObject::tr</a>() and <a href="qobject.html#trUtf8">QObject::trUtf8</a>() provide this functionality more conveniently.</p>
<p><i>context</i> is typically a class name (e.g&#x2e;, &quot;MyDialog&quot;) and <i>sourceText</i> is either English text or a short identifying text.</p>
<p><i>comment</i> is a disambiguating comment, for when the same <i>sourceText</i> is used in different roles within the same context. By default, it is null. <i>encoding</i> indicates the 8-bit encoding of character stings See the <a href="qtranslator.html">QTranslator</a> documentation for more information about contexts and comments.</p>
<p><i>n</i> is used in conjunction with <tt>%n</tt> to support plural forms. See <a href="qobject.html#tr">QObject::tr</a>() for details.</p>
<p>If none of the translation files contain a translation for <i>sourceText</i> in <i>context</i>, this function returns a <a href="qstring.html">QString</a> equivalent of <i>sourceText</i>. The encoding of <i>sourceText</i> is specified by <i>encoding</i>; it defaults to <a href="qcoreapplication.html#Encoding-enum">CodecForTr</a>.</p>
<p>This function is not virtual. You can use alternative translation techniques by subclassing <a href="qtranslator.html">QTranslator</a>.</p>
<p><b>Warning:</b> This method is reentrant only if all translators are installed <i>before</i> calling this method. Installing or removing translators while performing translations is not supported. Doing so will most likely result in crashes or other undesirable behavior.</p>
<p><b>Note:</b> This function is <a href="threads.html#reentrant">reentrant</a>.</p>
<p>See also <a href="qobject.html#tr">QObject::tr</a>(), <a href="qcoreapplication.html#installTranslator">installTranslator</a>(), and <a href="qtextcodec.html#codecForTr">QTextCodec::codecForTr</a>().</p>
<h3 class="fn"><a name="translate-2"></a><a href="qstring.html">QString</a> QCoreApplication::translate ( const char * <i>context</i>, const char * <i>sourceText</i>, const char * <i>comment</i> = 0, <a href="qcoreapplication.html#Encoding-enum">Encoding</a> <i>encoding</i> = CodecForTr )&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>This is an overloaded member function, provided for convenience.</p>
<h3 class="fn"><a name="winEventFilter"></a>bool QCoreApplication::winEventFilter ( MSG * <i>msg</i>, long * <i>result</i> )&nbsp;&nbsp;<tt> [virtual]</tt></h3>
<p>The message procedure calls this function for every message received. Reimplement this function if you want to process window messages <i>msg</i> that are not processed by Qt. If you don't want the event to be processed by Qt, then return true and set <i>result</i> to the value that the window procedure should return. Otherwise return false.</p>
<p>It is only directly addressed messages that are filtered. To handle system wide messages, such as messages from a registered hot key, you need to install an event filter on the event dispatcher, which is returned from <a href="qabstracteventdispatcher.html#instance">QAbstractEventDispatcher::instance</a>().</p>
<hr />
<h2>Related Non-Members</h2>
<h3 class="fn"><a name="qAddPostRoutine"></a>void qAddPostRoutine ( QtCleanUpFunction <i>ptr</i> )</h3>
<p>Adds a global routine that will be called from the <a href="qapplication.html">QApplication</a> destructor. This function is normally used to add cleanup routines for program-wide functionality.</p>
<p>The function specified by <i>ptr</i> should take no arguments and should return nothing. For example:</p>
<pre> static int *global_ptr = 0;

 static void cleanup_ptr()
 {
     delete [] global_ptr;
     global_ptr = 0;
 }

 void init_ptr()
 {
     global_ptr = new int[100];      <span class="comment">//</span> allocate data
     qAddPostRoutine(cleanup_ptr);   <span class="comment">//</span> delete later
 }</pre>
<p>Note that for an application- or module-wide cleanup, qAddPostRoutine() is often not suitable. For example, if the program is split into dynamically loaded modules, the relevant module may be unloaded long before the <a href="qapplication.html">QApplication</a> destructor is called.</p>
<p>For modules and libraries, using a reference-counted initialization manager or Qt's parent-child deletion mechanism may be better. Here is an example of a private class that uses the parent-child mechanism to call a cleanup function at the right time:</p>
<pre> class MyPrivateInitStuff : public QObject
 {
 public:
     static MyPrivateInitStuff *initStuff(QObject *parent)
     {
         if (!p)
             p = new MyPrivateInitStuff(parent);
         return p;
     }

     ~MyPrivateInitStuff()
     {
         <span class="comment">//</span> cleanup goes here
     }

 private:
     MyPrivateInitStuff(QObject *parent)
         : QObject(parent)
     {
         <span class="comment">//</span> initialization goes here
     }

     MyPrivateInitStuff *p;
 };</pre>
<p>By selecting the right parent object, this can often be made to clean up the module's data at the right moment.</p>
<hr />
<h2>Macro Documentation</h2>
<h3 class="fn"><a name="Q_DECLARE_TR_FUNCTIONS"></a>Q_DECLARE_TR_FUNCTIONS (  <i>context</i> )</h3>
<p>The Q_DECLARE_TR_FUNCTIONS() macro declares and implements two translation functions, <tt>tr()</tt> and <tt>trUtf8()</tt>, with these signatures:</p>
<pre> static inline QString tr(const char *sourceText,
                          const char *comment = 0);
 static inline QString trUtf8(const char *sourceText,
                              const char *comment = 0);</pre>
<p>This macro is useful if you want to use <a href="qobject.html#tr">QObject::tr</a>() or <a href="qobject.html#trUtf8">QObject::trUtf8</a>() in classes that don't inherit from <a href="qobject.html">QObject</a>.</p>
<p>Q_DECLARE_TR_FUNCTIONS() must appear at the very top of the class definition (before the first <tt>public:</tt> or <tt>protected:</tt>). For example:</p>
<pre> class MyMfcView : public CView
 {
     Q_DECLARE_TR_FUNCTIONS(MyMfcView)

 public:
     MyMfcView();
     ...
 };</pre>
<p>The <i>context</i> parameter is normally the class name, but it can be any string.</p>
<p>See also <a href="qobject.html#Q_OBJECT">Q_OBJECT</a>, <a href="qobject.html#tr">QObject::tr</a>(), and <a href="qobject.html#trUtf8">QObject::trUtf8</a>().</p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="30%">Copyright &copy; 2008 <a href="trolltech.html">Trolltech</a></td>
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
<td width="30%" align="right"><div align="right">Qt 4.3.5</div></td>
</tr></table></div></address></body>
</html>
